<?php



require "database.php";

$_____id_____   =$_GET["id"];
$_____poin_____ =(int)$_GET["poin"];

$copyorder=file_get_contents("copyorder.json");
$copyorder=json_decode($copyorder,1);

$_____order_____=file_get_contents("order.json");
$_____order_____=json_decode($_____order_____,1);

$issue=file_get_contents("issue.json");
$issue=json_decode($issue,1);
$issue=$issue[count($issue)-1]["issue"];


for ($i = 0; $i < count($copyorder); $i++) {
    if($copyorder[$i]["issue"]==$issue && $copyorder[$i]["id"]==$_____id_____){
        
        for ($x = 0; $x < count($_____order_____); $x++) {
            if($copyorder[$i]["tree_id"]==$_____order_____[$x]["tree_id"] && $copyorder[$i]["pid"]==$_____order_____[$x]["pid"]){
                $_____order_____[$x]["poin"]=$_____poin_____;
                
            }
        }
    }
}

$p=1;
for ($i = 0; $i < count($copyorder); $i++) {
    $copyorder[$i]["id"]=$p;
    $p++;
}


$_____order_____=json_encode($_____order_____,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
file_put_contents("order.json",$_____order_____);
